<?php
$g4_path = "../"; 
require_once ($g4_path.'common.php');

$title = "Super admin";
$menu = 5;
require_once ('./admin.head.php');
require_once ('./admin.lib.php');

if($_POST) {
    if($_POST['mode'] == 'del') {
            if(isset($_POST['mb_no'])) {
                $arr = implode(',', $_POST['mb_no']);
                $sql = "DELETE FROM g4_member WHERE mb_no IN ($arr)";
                mysql_query($sql);
                $affected = mysql_affected_rows();
            }
    }

    if($_POST['mode'] == 'write') {
            $required = array(
                'mb_name'=>'이름',
                'mb_hp'=>'핸드폰',
                'mb_id'=>'아이디',
                'mb_password'=>'Password',
            );
            requireProcess($required);

            $_POST['mb_password'] = sql_password($_POST['mb_password']);
            if($_POST['mb_division'] =='최고관리자') $_POST['mb_level'] = '10';
            if($_POST['mb_division'] =='일반관리자') $_POST['mb_level'] = '9';
            $fields = array(
                'mb_name',
                'mb_hp',
                'mb_id',
                'mb_password',
                'mb_division',
                'mb_level',
            );
            $res = putDb('g4_member', $_POST, $fields);
    }
}

$sql = "SELECT * FROM g4_member WHERE mb_division = '일반관리자' OR mb_division = '최고관리자'";
$res = mysql_query($sql);
$count = 0;
while($temp = mysql_fetch_assoc($res)) {
    $temp['count'] = ++$count;
    $data[] = $temp;
}
$tpl->define('basic',"superMembers.html");
$tpl->print_('basic');

require_once('admin.foot.php');
